<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:c="livcos.org/ns/cosmos"
  xmlns="http://www.w3.org/1999/xhtml"
  exclude-result-prefixes="c">
  
  <xsl:import href="../meta.xsl"/>
  
	<xsl:template match="/*">
		<xsl:apply-templates select="." mode="title"/>
		<xsl:apply-imports/>
	</xsl:template>
	
	<xsl:template match="/*" mode="title">
		<h1>Exception!</h1>
		<xsl:apply-templates select="exception" mode="msg"/>
	</xsl:template>
	
	<xsl:template match="exception" mode="msg">
    <p>
      <xsl:for-each select="ancestor::exception">
        <xsl:text>- </xsl:text>        
      </xsl:for-each>
      <xsl:choose>
        <xsl:when test="message">
          <xsl:value-of select="message"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="@type"/>
        </xsl:otherwise>
      </xsl:choose>
    </p>
    <xsl:apply-templates select="exception" mode="msg"/>
  </xsl:template>
  
</xsl:stylesheet>
